// KnotTime.cpp :
//

#include "stdafx.h"
#include "KnotTime.h"
#include "Knot.h"


IMPLEMENT_DYNAMIC(CKnotTime, CDialog)

CKnotTime::CKnotTime(CWnd* pParent /*=NULL*/)
	: CDialog(CKnotTime::IDD, pParent),
	  m_pKnot(NULL)
{

}

CKnotTime::~CKnotTime()
{
}

BOOL CKnotTime::OnInitDialog()
{
	return CDialog::OnInitDialog();
}

void CKnotTime::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT1, m_TimeValueEdit);
}


BEGIN_MESSAGE_MAP(CKnotTime, CDialog)
	ON_BN_CLICKED(IDOK, &CKnotTime::OnBnClickedOk)
END_MESSAGE_MAP()


void CKnotTime::OnBnClickedOk()
{
	CString strText;
	m_TimeValueEdit.GetWindowTextW(strText);
	long lTime = atol((LPSTR)(LPCTSTR)strText);
	m_pKnot->SetTime(lTime);
	HTREEITEM item = m_pKnot->GetTreeItem();

	CString strKnot;
	strKnot.Format(_T("%s : %d"), m_pKnot->GetName(), m_pKnot->GetTime());
	m_pTree->SetItemText(item, strKnot);
	
	OnOK();
}
